﻿// Decompiled with JetBrains decompiler
// Type: MTTrade.Util.JsonFileHelper
// Assembly: MT5Trade, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 8045A2CB-DBD6-41AD-8804-F98CAC1BDC8D
// Assembly location: C:\projects\trade\trade_tool\trade0812\MT5Trade.dll

using Commom.Util;
using Newtonsoft.Json;
using System.IO;

#nullable enable
namespace MTTrade.Util;

public static class JsonFileHelper
{
  public static T ReadFromFile<T>(string filePath)
  {
    return !File.Exists(filePath) ? default (T) : File.ReadAllText(filePath).JsonToEntity<T>();
  }

  public static void WriteToFile<T>(string filePath, T obj)
  {
    string contents = JsonConvert.SerializeObject((object) obj, Formatting.Indented);
    File.WriteAllText(filePath, contents);
  }
}
